<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class HomeRegisterPostRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|max:32',
            'password' => 'required',
            'repassword' => 'required|same:password',
            'email' => 'required|email',
        ];
    }
    /*
        用户显示字段的错误信息
    */
    public function messages()
    {
        return [
            'username.required'=>'用户名必须填写', 
            'username.max'=>'用户名必须小于32位',
            'password.required'=>'密码必须填写', 
            'repassword.required'=>'确认密码不能为空',
            'repassword.same'=>'两次密码不一致',
            'email.required'=>'邮箱不能为空',
            'email.email'=>'邮箱格式不正确',
        ];
    }
}
